import { createRouter, createWebHashHistory } from 'vue-router';

const Login = () => import( /* webpackChunkName:'login' */ '@/views/Login/index.vue');

const Layout = () => import( /* webpackChunkName:'Layout' */ '@/Layout/index.vue');

const Dashboard = () => import( /* webpackChunkName:'Dashboard' */ '@/views/Dashboard/index.vue');

const Permission = () =>
  import( /* webpackChunkName:'permission' */ '@/views/Permission/index.vue');
const User = () => import( /* webpackChunkName:'User' */ '@/views/User/index.vue');
const Role = () => import( /* webpackChunkName:'Role' */ '@/views/Role/index.vue');
const UserProfile = () =>
  import( /* webpackChunkName:'userProfile' */ '@/views/UserProfile/index.vue');

const Department = () =>
  import( /* webpackChunkName:'department' */ '@/views/Department/index.vue');
const Jobs = () => import( /* webpackChunkName:'jobs' */ '@/views/Jobs/index.vue');
const Dictionary = () =>
  import( /* webpackChunkName:'dictionary' */ '@/views/Dictionary/index.vue');
const DictionaryData = () =>
  import( /* webpackChunkName:'dictionaryData' */ '@/views/DictionaryData/index.vue');

const H5ShopDecoration = () =>
  import(
    /* webpackChunkName:'h5ShopDecoration' */
    '@/views/ShopDecoration/H5ShopDecoration/index.vue'
  );
const PcShopDecoration = () =>
  import(
    /* webpackChunkName:'pcShopDecoration' */
    '@/views/ShopDecoration/PcShopDecoration/index.vue'
  );

const H5ShopDecorationEdit = () =>
  import(
    /* webpackChunkName:'h5ShopDecorationEdit' */
    '@/views/ShopDecoration/H5ShopDecoration/edit.vue'
  );

/**
 * Note: 路由配置项
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * meta : {
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */
export const asyncRoutes = [
  {
    path: '/dashboard',
    component: Layout,
    meta: {
      title: '首页',
      icon: 'dash-board'
    },
    children: [
      {
        path: '',
        component: Dashboard,
        meta: {
          title: '首页',
          icon: 'dash-board'
        }
      }
    ]
  },
  {
    path: '/shopDecoration',
    component: Layout,
    meta: {
      title: '营销管理',
      icon: 'yingxiaoguanli'
    },
    children: [{
      path: 'h5ShopDecoration',
      component: H5ShopDecoration,
      meta: {
        title: '移动端店铺管理',
        icon: 'zhuangxiudianpu'
      }
    },
    {
      path: 'pcShopDecoration',
      component: PcShopDecoration,
      meta: {
        title: 'PC端店铺管理',
        icon: 'dianpuzhuangxiu'
      }
    },
    {
      path: 'h5ShopDecorationEdit/:id',
      component: H5ShopDecorationEdit,
      hidden: true,
      meta: {
        title: '移动端店铺装修',
        icon: 'zhuangxiudianpu'
      }
    },
    {
      path: 'pcShopDecorationEdit/:id',
      component: H5ShopDecorationEdit,
      hidden: true,
      meta: {
        title: 'PC端店铺装修',
        icon: 'zhuangxiudianpu'
      }
    }
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: 'noRedirect',
    meta: {
      title: '系统管理',
      icon: 'xitong'
    },
    children: [{
      path: 'user',
      component: User,
      meta: {
        title: '用户管理',
        icon: 'user-fill'
      }
    },
    {
      path: 'role',
      component: Role,
      meta: {
        title: '角色管理',
        icon: 'jiaose'
      }
    },
    {
      path: 'permission',
      component: Permission,
      meta: {
        title: '权限管理',
        icon: 'tree-table'
      }
    },
    {
      path: 'department',
      component: Department,
      meta: {
        title: '部门管理',
        icon: 'bumenguanli'
      }
    },
    {
      path: 'jobs',
      component: Jobs,
      meta: {
        title: '岗位管理',
        icon: 'qiyeguanli_gangweiguanli'
      }
    },
    {
      path: 'dictionary',
      component: Dictionary,
      meta: {
        title: '字典管理',
        icon: 'zidianguanli'
      }
    },
    {
      path: 'dictionaryData/:id',
      component: DictionaryData,
      hidden: true,
      meta: {
        title: '字典数据管理',
        icon: 'zidianguanli'
      }
    },
    {
      path: 'userProfile',
      component: UserProfile,
      hidden: true,
      meta: {
        title: '个人中心'
      }
    }
    ]
  }
];

const routes = [{
  path: '/login',
  name: 'Login',
  hidden: true,
  component: Login,
  meta: {
    title: '登录'
  }
}
];

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes,
  scrollBehavior() {
    return {
      left: 0,
      top: 0
    };
  }
});

export default router;

